<?php include 'inc/header.php'; ?>
<?php
$sql = 'SELECT * FROM review';
$result = mysqli_query($conn, $sql);
$reviews = mysqli_fetch_all($result, MYSQLI_ASSOC);
/*
  $reviews = {
      [
        'id'=>1,
        'name'=>'张三',
        'email'=>'zhangsan@example.com',
        'course_name'=>'计算机科学',
        'content'=>'这门课很适合初学者',
        'date'=>'2024-03-25 08:00:00',
      ],

      [
        'id'=>2,
        'name'=>'李四',
        'email'=>'lisi@example.com',
        'course_name'=>'数据科学基础',
        'content'=>'非常实用的课程',
        'date'=>'2024-03-26 09:00:00',
      ],

      [
        'id'=>3,
        'name'=>'王五',
        'email'=>'wangwu@example.com',
        'course_name'=>'前端开发入门',
        'content'=>'课程内容丰富',
        'date'=>'2024-03-27 10:00:00',
      ],
      
  };
  */
?>
<h2>课程评价</h2>

<?php if(empty($reviews)): ?>
  <p class="lead mt3">目前没有课程评价！</p>
<?php endif; ?>

<?php foreach($reviews as $review):?>
      <div class="card my-3" style="width: 18rem;">
      <div class ="card-title text-center mt-2">
        <?php echo $review['course_name'];?>
      </div>  
      <div class="card-body text-center">
        “<?php echo $review['content']?>”
        <div class ="text-secondary mt-2">
          来自<?php echo $review['name'];?>
          <?php echo $review['date'];?>
        </div>

        </div>
      </div>
      <?php endforeach; ?>
    
<?php include 'inc/footer.php'; ?>
